package com.bdqn.bookshop.controller.admin;

import com.bdqn.bookshop.entity.Guide;
import com.bdqn.bookshop.service.GuideService;
import com.bdqn.bookshop.utils.DataGridViewResult;
import com.bdqn.bookshop.utils.Result;
import com.bdqn.bookshop.vo.GuideVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author : 罗若然[LUO_RUO_RAN]
 * @date : 2020-07-29 15:10
 **/
@RestController
@RequestMapping("/admin/guide")
public class AdminGuideController {

    @Autowired
    private GuideService guideService;

    @RequestMapping("/guideList")
    public DataGridViewResult guideList(GuideVo guideVo){
        return guideService.guideList(guideVo);
    }

    @PostMapping("/uploadImage")
    public Map<String,Object> uploadImage(MultipartFile file, HttpServletRequest request){
        return guideService.uploadImage(file,request);
    }

    @PostMapping("/addGuide")
    public Result addGuide(Guide guide,HttpServletRequest request){
        return guideService.addGuide(guide,request);
    }

    @PostMapping("/updateGuide")
    public Result updateGuide(Guide guide,HttpServletRequest request){
        return guideService.updateGuide(guide,request);
    }

    @RequestMapping("/deleteById")
    public Result deleteById(Integer id){
        return guideService.deleteById(id);
    }

    @RequestMapping("/batchDelete")
    public Result batchDelete(String ids){
        return  guideService.batchDelete(ids);
    }
}
